//
//  UCommUtil.m
//  app
//
//  Created by CI Mark on 2017/12/16.
//  Copyright © 2017年 CI Mark. All rights reserved.
//

#import "UCommUtil.h"

@implementation UCommUtil

/**
 dictionary转成网络String
 
 @param dictionary 需要转换的dictionary
 @return 返回的String
 */
+(NSString*)DictionaryTOUrlString:(NSDictionary*)dictionary{
    NSString* string  = @"";
    NSArray * allkeys = [dictionary allKeys];
    NSLog(@"allkeys %@",allkeys);
    for (int i = 0; i < allkeys.count; i++) {
        NSString * key = [allkeys objectAtIndex:i];
        //如果你的字典中存储的多种不同的类型,那么最好用id类型去接受它
        id obj  = [dictionary objectForKey:key];
        if ([obj isKindOfClass:[NSString class]]) {
            if ([@"" isEqual:string]) {
                string = [NSString stringWithFormat:@"%@=%@",key,obj];
            }else{
                string = [NSString stringWithFormat:@"%@&%@=%@",string,key,obj];;
            }
        }else{
            NSLog(@"参数类型有错");
        }
        NSLog(@"obj %@",obj);
    }
    return string;
}

@end
